|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Ws4J2eeProperties.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.toWs;
|
|
18 |
|
|
19 |
import java.io.File;
|
|
20 |
import java.io.FileInputStream;
|
|
21 |
import java.io.InputStream;
|
|
22 |
import java.util.ArrayList;
|
|
23 |
import java.util.Properties;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* @author hemapani@opensource.lk
|
|
27 |
*/
|
|
28 |
public class Ws4J2eeProperties { |
|
29 |
private Properties properties;
|
|
30 |
/**
|
|
31 |
* these a properties of the files or dir
|
|
32 |
* they are checked are they really exists
|
|
33 |
*/
|
|
34 |
private ArrayList properitesToCheck;
|
|
35 |
|
|
36 | 0 |
public Ws4J2eeProperties() {
|
37 | 0 |
properties = new Properties();
|
38 | 0 |
properitesToCheck = new ArrayList();
|
39 | 0 |
properitesToCheck.add(GenerationConstants.AXIS_WEBAPPS_LIB); |
40 | 0 |
properitesToCheck.add(GenerationConstants.EJB_DEPLOY_DIR); |
41 | 0 |
properitesToCheck.add(GenerationConstants.MAVEN_LOCAL_REPOSITARY); |
42 | 0 |
loadProperties(); |
43 | 0 |
checkProperties(); |
44 |
} |
|
45 |
|
|
46 | 0 |
public String getProperty(String key) {
|
47 | 0 |
return properties.getProperty(key);
|
48 |
} |
|
49 |
|
|
50 | 0 |
private void checkProperties() { |
51 | 0 |
for (int i = 0; i < properitesToCheck.size(); i++) { |
52 | 0 |
String key = (String) properitesToCheck.get(i); |
53 | 0 |
String value = properties.getProperty(key); |
54 | 0 |
if (value != null) { |
55 | 0 |
File file = new File(value);
|
56 | 0 |
if (!file.exists()) {
|
57 | 0 |
properties.remove(key); |
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 | 0 |
private void loadProperties() { |
64 | 0 |
InputStream proIn = null;
|
65 | 0 |
proIn = GenerationConstants.class.getResourceAsStream(GenerationConstants.WS4J2EE_PROPERTY_FILE);
|
66 | 0 |
try {
|
67 | 0 |
if (proIn == null) { |
68 | 0 |
File file = new File("conf/" + GenerationConstants.WS4J2EE_PROPERTY_FILE); |
69 | 0 |
if (file.exists()) {
|
70 | 0 |
proIn = new FileInputStream(file);
|
71 |
} |
|
72 |
} |
|
73 | 0 |
if (proIn == null) { |
74 | 0 |
proIn = GenerationConstants.class.getResourceAsStream("META-INF/" + GenerationConstants.WS4J2EE_PROPERTY_FILE); |
75 |
} |
|
76 | 0 |
if (proIn == null) { |
77 | 0 |
proIn = new FileInputStream(GenerationConstants.WS4J2EE_PROPERTY_FILE);
|
78 |
} |
|
79 | 0 |
if (proIn != null) { |
80 | 0 |
properties.load(proIn); |
81 |
} |
|
82 |
} catch (Exception e) {
|
|
83 | 0 |
throw new UnrecoverableGenerationFault(e); |
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
|
|